/*
	Author: Superxpdude
	
	Description:
	Handles the automatic player ranking system.
	This should only ever be run on the computer where the player is local.
	
	Parameters:
	None
	
	Example:
	[] call SXP_fnc_rankUP;
	
	Returns:
	Nothing
*/
private ["_player"];

// Define variables
_player = player;
SXP_playerScore = score player;

// Define points required for various ranks
_rank1 = 10; // Corporal
_rank2 = 25; // Sergeant
_rank3 = 45; // Lieutenant
_rank4 = 65; // Captain
_rank5 = 90; // Major
_rank6 = 120; // Colonel

// Set rank based on unit's points
switch (true) do {
	case ((SXP_playerScore < _rank1) and ((rank _player) != "PRIVATE")) : {
		["rank_change",["Private","\A3\ui_f\data\gui\cfg\Ranks\private_gs.paa"]] call BIS_fnc_showNotification;
		_player setUnitRank "PRIVATE";
	};
	case ((SXP_playerScore >= _rank1) and (SXP_playerScore < _rank2) and ((rank _player) != "CORPORAL")) : {
		["rank_change",["Corporal","\A3\ui_f\data\gui\cfg\Ranks\corporal_gs.paa"]] call BIS_fnc_showNotification;
		_player setUnitRank "CORPORAL";
	};
	case ((SXP_playerScore >= _rank2) and (SXP_playerScore < _rank3) and ((rank _player) != "SERGEANT")) : {
		["rank_change",["Sergeant","\A3\ui_f\data\gui\cfg\Ranks\sergeant_gs.paa"]] call BIS_fnc_showNotification;
		_player setUnitRank "SERGEANT";
	};
	case ((SXP_playerScore >= _rank3) and (SXP_playerScore < _rank4) and ((rank _player) != "LIEUTENANT")) : {
		["rank_change",["Lieutenant","\A3\ui_f\data\gui\cfg\Ranks\lieutenant_gs.paa"]] call BIS_fnc_showNotification;
		_player setUnitRank "LIEUTENANT";
	};
	case ((SXP_playerScore >= _rank4) and (SXP_playerScore < _rank5) and ((rank _player) != "CAPTAIN")) : {
		["rank_change",["Captain","\A3\ui_f\data\gui\cfg\Ranks\captain_gs.paa"]] call BIS_fnc_showNotification;
		_player setUnitRank "CAPTAIN";
	};
	case ((SXP_playerScore >= _rank5) and (SXP_playerScore < _rank6) and ((rank _player) != "MAJOR")) : {
		["rank_change",["Major","\A3\ui_f\data\gui\cfg\Ranks\major_gs.paa"]] call BIS_fnc_showNotification;
		_player setUnitRank "MAJOR";
	};
	case ((SXP_playerScore >= _rank6) and ((rank _player) != "COLONEL")) : {
		["rank_change",["Colonel","\A3\ui_f\data\gui\cfg\Ranks\colonel_gs.paa"]] call BIS_fnc_showNotification;
		_player setUnitRank "COLONEL";
	};
};